<#assign module="insurance"/>

<@override name="header">
</@override>

<@override name="body">

<div class="row">
    <div class="col-md-12">
        <div class="alert alert-info text-center" role="alert"><strong>提示!</strong> 暂未开通保险业务，仔细阅读并且同意《平安代驾责任险条款》后点击立即开通即可开通服务。</div>
    </div>
    <div class="col-md-12">
       <div style="border: 1px solid #c4e3f3;display: block;padding: 10px;height: 400px;overflow: scroll;">
        ${aggrement?if_exists}
       </div>
    </div>
    <div class="col-md-12">
        <p class="text-center checkbox">
            <label>
                <input type="checkbox" id="toubao_checkbox"/>我已仔细阅读并且同意《平安代驾责任险条款》
            </label>
        </p>
        <p class="text-center checkbox" style="margin-top: 20px;">
            <button type="button" class="btn btn-primary" id="toubao_btn">&nbsp;&nbsp;立即开通&nbsp;&nbsp;</button>
        </p>
    </div>
</div>

</@override>

<@override name="footer">
<script type="text/javascript">
$(document).ready(function(){
    $("#toubao_btn").click(function(){
        var checked = $("#toubao_checkbox").prop("checked");
        if(!checked){
            $.scojs_modal({
                title:'提示',
                content:'请先仔细阅读并且同意《平安代驾责任险条款》'
            }).show()
        }else{
            //开通
            $.post('${ctx}/insurances/create',null,function(data){
                if(data.success){
                    window.location = '${ctx}/insurances/charge';
                }else{
                    $.scojs_modal({
                        title:'失败',
                        content:'开通保险服务失败，请稍后再试'
                    }).show()
                }
            },'json');
        }
    });
});
</script>
</@override>

<@extends name="../layout.ftl"/>